<template>
  <div>
    <el-form ref="dataForm" v-model="query" class="form" :rules="rules">
      <el-form-item prop="limitSpare" label="微信下单未支付限时作废时间:">
        <el-input-number v-model="query.limitSpare" size="mini" controls-position="right" :min="0" :max="480" :precision="0" />
      </el-form-item>
      <el-form-item label="微信支付:">
        <br>
        <el-form-item label-width="80px">
          <el-checkbox v-model="query.ck_007_sys_setting_1_7">微信下单</el-checkbox>
          <el-checkbox v-model="query.ck_007_sys_setting_2_7">运气到家收款</el-checkbox>
        </el-form-item>
      </el-form-item>
      <el-form-item label="支付宝支付:">
        <br>
        <el-form-item label-width="80px">
          <el-checkbox v-model="query.ck_007_sys_setting_3_16">运气到家收款</el-checkbox>
        </el-form-item>
      </el-form-item>
      <el-form-item label="现金支付:">
        <br>
        <el-form-item label-width="80px">
          <el-checkbox v-model="query.ck_007_sys_setting_1_8">微信下单</el-checkbox>
        </el-form-item>
      </el-form-item>
      <el-form-item label="工行支付:">
        <br>
        <el-form-item label-width="80px">
          <el-checkbox v-model="query.ck_007_sys_setting_sp4_5">微信下单</el-checkbox>
          <el-checkbox v-model="query.ck_007_sys_setting_sp4_6">运气到家收款</el-checkbox>
          <el-checkbox v-model="query.ck_007_sys_setting_sp4_29">微信预付卡充值</el-checkbox>
        </el-form-item>
      </el-form-item>
      <el-form-item label="预付卡支付:">
        <br>
        <el-form-item label-width="80px">
          <el-checkbox v-model="query.ck_007_sys_setting_3_17">运气到家收款</el-checkbox>
        </el-form-item>
      </el-form-item>
      <el-form-item label="气票支付:">
        <br>
        <el-form-item label-width="80px">
          <el-checkbox v-model="query.ck_007_sys_setting_3_1">运气到家收款</el-checkbox>
        </el-form-item>
      </el-form-item>
      <el-form-item label="威富通支付:">
        <br>
        <el-form-item label-width="80px">
          <el-checkbox v-model="query.ck_007_sys_setting_2_21">运气到家收款</el-checkbox>
        </el-form-item>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'

  export default {
    name: 'PaywayTab',
    data() {
      return {
        query: {
          limitSpare: '',
          ck_007_sys_setting_1_7: false,
          ck_007_sys_setting_2_7: false,
          ck_007_sys_setting_3_16: false,
          ck_007_sys_setting_1_8: false,
          ck_007_sys_setting_sp4_5: false,
          ck_007_sys_setting_sp4_6: false,
          ck_007_sys_setting_sp4_29: false,
          ck_007_sys_setting_3_17: false,
          ck_007_sys_setting_3_1: false,
          ck_007_sys_setting_2_21: false
        },
        rules: {
          // le: [{ required: true, message: '请输入呼叫下单所属机构默认展开级数', trigger: 'change' }],
        }
      }
    },
    computed: {
      ...mapGetters([
        'corpSettingData', 'userInfo'
      ])
    },
    watch: {
      'query.ck_007_sys_setting_1_7': {
        async handler(newVal, oldVal) {
          if (newVal) {
            this.$bus.$emit('ck_007_sys_setting_1_7', false)
          }
        },
        deep: true,
        immediate: true
      }
    },
    created() {
      this.init()
    },
    mounted() {
      this.$bus.$on('ck_007_sys_setting_1_6', (data) => {
        this.query.ck_007_sys_setting_1_7 = data
      })
    },
    methods: {
      init() {
        if (this.corpSettingData) {
          this.query.limitSpare = this.corpSettingData.limitSpare || ''
          this.query.ck_007_sys_setting_1_1 = !!(this.corpSettingData.sp1 >> 1 & 0x01)
          this.query.ck_007_sys_setting_1_7 = !!(this.corpSettingData.sp1 >> 7 & 0x01)
          this.query.ck_007_sys_setting_2_7 = !!(this.corpSettingData.sp2 >> 7 & 0x01)
          this.query.ck_007_sys_setting_3_16 = !!(this.corpSettingData.sp3 >> 16 & 0x01)
          this.query.ck_007_sys_setting_1_8 = !!(this.corpSettingData.sp1 >> 8 & 0x01)
          this.query.ck_007_sys_setting_sp4_5 = !!(this.corpSettingData.sp4 >> 5 & 0x01)
          this.query.ck_007_sys_setting_sp4_6 = !!(this.corpSettingData.sp4 >> 6 & 0x01)
          this.query.ck_007_sys_setting_sp4_29 = !!(this.corpSettingData.sp4 >> 29 & 0x01)
          this.query.ck_007_sys_setting_3_17 = !!(this.corpSettingData.sp3 >> 17 & 0x01)
          this.query.ck_007_sys_setting_3_1 = !!(this.corpSettingData.sp3 >> 1 & 0x01)
          this.query.ck_007_sys_setting_2_21 = !!(this.corpSettingData.sp2 >> 21 & 0x01)
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
.form {
  .el-form-item {
    margin-bottom: 0;
  }
}
</style>
